<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="admin/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="admin/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<p th:text="${reportNo}" style="display: none" id="reportNo"></p>

<form class="layui-form layuimini-form" id="up_form" action="">
    <div class="layui-form-item">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">驳回原因</label>
            <div class="layui-input-block">
                <textarea id="rejectText" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="layui-btn" lay-submit lay-filter="formDemo">立即驳回</button>
            </div>
        </div>
    </div>

</form>
<script src="admin/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            laydate = layui.laydate,
            upload = layui.upload;
            $ = layui.$;


            $('#layui-btn').click(function () {
                if ($('#rejectText').val()===''){
                    alert("请输入驳回原因")
                    return;
                }



                $.ajax({
                    type:'get',
                    url:'report/dealReject',
                    beforeSend: function (XMLHttpRequest) {
                        XMLHttpRequest.setRequestHeader("token", window.sessionStorage.getItem("token"));
                    },
                    async:false,
                    data:{
                        rejectText:$('#rejectText').val(),
                        reportNo:$('#reportNo').text()
                    },
                    success:function (res) {
                        if (res != null){
                            alert('驳回成功')
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            parent.location.href = 'toReportIndex';
                        }

                    },
                    error:(err)=>{
                        alert(err)
                    }
                });
            })

    });
</script>
</body>
</html>